from rank.feature import Feature


class RelativeFeature(Feature):
    def get_feature(self, global_resource, request_content, response_content):
        merge_result = response_content.get_value("merge_result")
        follow_list = set(request_content.get_value("follower_id_list"))
        relative_feature = {}
        for api_id, api in merge_result.items():
            max_val = 0
            for developer in api["developer_ids"]:
                if developer in follow_list:
                    max_val = 1
                    break
            relative_feature[api_id] = max_val
        response_content.store_value("relative_feature", relative_feature)
